#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;


class Solution {
public:

    static const int N = 3e4 + 10;
    static const int offs = 1e4;

    struct Node
    {
        int l, r, sum;
    }node[N * 4];


    void pushup(int u){
        node[u].sum = node[u << 1].sum + node[u << 1 | 1].sum;
    }

    void build(int u, int l, int r){
        node[u].l = l, node[u].r = r, node[u].sum = 0;
        if(l == r)return;
        int mid = (l + r) >> 1;
        build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
    }


    void insert(int u, int k){
        if(node[u].l == k && node[u].r == k){
            node[u].sum += 1;
        }else{
            int mid = (node[u].l + node[u].r) >> 1;
            if(k <= mid) insert(u << 1, k);
            if(k > mid) insert(u << 1 | 1, k);
            pushup(u);
        }
    }
    
    int query(int u, int l, int r){
        if(node[u].l >= l && node[u].r <= r){
            return node[u].sum;
        }else{
            int res = 0;
            int mid = (node[u].l + node[u].r) >> 1;
            if(l <= mid) res += query(u << 1, l, r);
            if(r > mid) res += query(u << 1 | 1, l, r);
            return res;
        }
    }

    vector<int> countSmaller(vector<int>& nums) {
        vector<int> res;
        memset(node, 0, sizeof node);
        build(1, 0, 20000);

        for(int i = nums.size() - 1; i >= 0; i --){
            nums[i] += offs;
            if(nums[i] == 0){
                res.push_back(0);
            }else{
                res.push_back(query(1, 0, nums[i] - 1));
            }
            insert(1, nums[i]);
        }

        reverse(res.begin(), res.end());
        return res;
        
    }
};

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);


    return 0;
}